package com.nova.bluetooth.ui.bluetoothDemo;

import android.util.Log;

import com.nova.bluetooth.bean.SupportFunctionBean;

import java.util.ArrayList;
import java.util.List;

/**
 *  设备功能配置类
 */
public class NovaDeviceConfigMessage {
    public final static int DEVICE_TYPE_TWS = 0;
    public final static int DEVICE_TYPE_HEADSET = 1;
    public final static int DEVICE_TYPE_BOX = 2;

    public final static int TWS_SUPPORT_ID_0105 = 0x0105;
    public final static int TWS_SUPPORT_ID_0106 = 0x0106;
    public final static int TWS_SUPPORT_ID_0107 = 0x0107;
    public final static int TWS_SUPPORT_ID_0108 = 0x0108;
    public final static int TWS_SUPPORT_ID_0109 = 0x0109;
    public final static int TWS_SUPPORT_ID_010a = 0x010a;
    public final static int TWS_SUPPORT_ID_010b = 0x010b;
    public final static int TWS_SUPPORT_ID_010c = 0x010c;
    public final static int TWS_SUPPORT_ID_010d = 0x010d;
    public final static int TWS_SUPPORT_ID_010e = 0x010e;
    public final static int TWS_SUPPORT_ID_010f = 0x010f;
    public final static int TWS_SUPPORT_ID_0110 = 0x0110;
    public final static int TWS_SUPPORT_ID_0111 = 0x0111;
    public final static int TWS_SUPPORT_ID_0112 = 0x0112;
    public final static int TWS_SUPPORT_ID_0113 = 0x0113;
    public final static int TWS_SUPPORT_ID_0114 = 0x0114;
    public final static int TWS_SUPPORT_ID_0115 = 0x0115;



    public static List<SupportFunctionBean> getTwsSupportFunctionList() {
        //TWS耳机功能列表初始化
        List<SupportFunctionBean> twsSupportFunctionList = new ArrayList<>();
//        twsSupportFunctionList.add(new SupportFunctionBean(0x0101, "音量设置与查询（0x01-0x03）", false));
//        twsSupportFunctionList.add(new SupportFunctionBean(0x0102, "播放控制（0x07-0x0a）", false));
//        twsSupportFunctionList.add(new SupportFunctionBean(0x0103, "蓝牙配对（0x10）", false));
//        twsSupportFunctionList.add(new SupportFunctionBean(0x0104, "BT蓝牙断开（0x11）", false));
        twsSupportFunctionList.add(new SupportFunctionBean(TWS_SUPPORT_ID_0105, "BLE蓝牙断开", true, true));
        twsSupportFunctionList.add(new SupportFunctionBean(TWS_SUPPORT_ID_0106, "入耳检测", false));
//        twsSupportFunctionList.add(new SupportFunctionBean(0x0107, "关机（0x20）", false));
        twsSupportFunctionList.add(new SupportFunctionBean(TWS_SUPPORT_ID_0108, "游戏模式", false));
        twsSupportFunctionList.add(new SupportFunctionBean(TWS_SUPPORT_ID_0109, "恢复出厂设置", false));
        twsSupportFunctionList.add(new SupportFunctionBean(TWS_SUPPORT_ID_010a, "左右耳电量", true, true));
        twsSupportFunctionList.add(new SupportFunctionBean(TWS_SUPPORT_ID_010b, "外壳电量", false));
        twsSupportFunctionList.add(new SupportFunctionBean(TWS_SUPPORT_ID_010c, "按键功能设置与查询", true, true));
        twsSupportFunctionList.add(new SupportFunctionBean(TWS_SUPPORT_ID_010d, "EQ获取与设置", true, true));
        twsSupportFunctionList.add(new SupportFunctionBean(TWS_SUPPORT_ID_010e, "噪声控制", false));
        twsSupportFunctionList.add(new SupportFunctionBean(TWS_SUPPORT_ID_010f, "设备查找", false));

//        twsSupportFunctionList.add(new SupportFunctionBean(TWS_SUPPORT_ID_0110, "睡眠模式（0x63-0x65）", false));
        twsSupportFunctionList.add(new SupportFunctionBean(TWS_SUPPORT_ID_0111, "空间音效模式", false));
//        twsSupportFunctionList.add(new SupportFunctionBean(TWS_SUPPORT_ID_0112, "沉浸式音频模式（0x81）", false));
//        twsSupportFunctionList.add(new SupportFunctionBean(TWS_SUPPORT_ID_0113, "专注模式（0x86）", false));
//        twsSupportFunctionList.add(new SupportFunctionBean(TWS_SUPPORT_ID_0114, "简易AI-对耳翻译模式开关指令（0x51）", false));
//        twsSupportFunctionList.add(new SupportFunctionBean(TWS_SUPPORT_ID_0115, "简易AI-录音转写模式开关指令（0x52）", false));
        return twsSupportFunctionList;
    }


    public final static int HEADSET_SUPPORT_ID_0201 = 0x0201;
    public final static int HEADSET_SUPPORT_ID_0202 = 0x0202;
    public final static int HEADSET_SUPPORT_ID_0203 = 0x0203;
    public final static int HEADSET_SUPPORT_ID_0204 = 0x0204;
    public final static int HEADSET_SUPPORT_ID_0205 = 0x0205;
    public final static int HEADSET_SUPPORT_ID_0206 = 0x0206;
    public final static int HEADSET_SUPPORT_ID_0207 = 0x0207;
    public final static int HEADSET_SUPPORT_ID_0208 = 0x0208;
    public final static int HEADSET_SUPPORT_ID_0209 = 0x0209;
    public final static int HEADSET_SUPPORT_ID_020a = 0x020a;
    public final static int HEADSET_SUPPORT_ID_020b = 0x020b;

    public static List<SupportFunctionBean> getHeadsetSupportFunctionList() {
        //骨气传导功能列表初始化
        List<SupportFunctionBean> headsetSupportFunctionList = new ArrayList<>();
//        headsetSupportFunctionList.add(new SupportFunctionBean(HEADSET_SUPPORT_ID_0201, "音量设置与查询（0x00-0x02）", true, true));
//        headsetSupportFunctionList.add(new SupportFunctionBean(HEADSET_SUPPORT_ID_0202, "播放控制（0x07-0x0a）", true, true));
//        headsetSupportFunctionList.add(new SupportFunctionBean(HEADSET_SUPPORT_ID_0203, "EQ获取与设置（0x76、0x39）", true, true));
//        headsetSupportFunctionList.add(new SupportFunctionBean(0x0204, "蓝牙配对（0x10）", false));
//        headsetSupportFunctionList.add(new SupportFunctionBean(0x0205, "BT蓝牙断开（0x11）", false));
        headsetSupportFunctionList.add(new SupportFunctionBean(HEADSET_SUPPORT_ID_0206, "BLE蓝牙断开", true, true));
//        headsetSupportFunctionList.add(new SupportFunctionBean(HEADSET_SUPPORT_ID_0207, "恢复出厂设置（0x30）", true, true));
//        headsetSupportFunctionList.add(new SupportFunctionBean(HEADSET_SUPPORT_ID_0208, "获取电量（0x33）", true, true));
//        headsetSupportFunctionList.add(new SupportFunctionBean(0x0209, "蓝牙耳机LED状态获取（0x34）", false));
//        headsetSupportFunctionList.add(new SupportFunctionBean(HEADSET_SUPPORT_ID_020a, "TF模式设置、蓝牙模式设置、获取TF模式状态（0x45、0x46、0x48）", false));
//        headsetSupportFunctionList.add(new SupportFunctionBean(HEADSET_SUPPORT_ID_020b, "噪声控制（0x60-0x61）", false));
        return headsetSupportFunctionList;
    }

    public final static int BOX_SUPPORT_ID_0301 = 0x0301;
    public final static int BOX_SUPPORT_ID_0302 = 0x0302;
    public final static int BOX_SUPPORT_ID_0303 = 0x0303;
    public final static int BOX_SUPPORT_ID_0304 = 0x0304;
    public final static int BOX_SUPPORT_ID_0305 = 0x0305;
    public final static int BOX_SUPPORT_ID_0306 = 0x0306;
    public final static int BOX_SUPPORT_ID_0307 = 0x0307;
    public final static int BOX_SUPPORT_ID_0308 = 0x0308;
    public final static int BOX_SUPPORT_ID_0309 = 0x0309;
    public final static int BOX_SUPPORT_ID_030a = 0x030a;
    public final static int BOX_SUPPORT_ID_030b = 0x030b;
    public final static int BOX_SUPPORT_ID_030c = 0x030c;
    public final static int BOX_SUPPORT_ID_030d = 0x030d;
    public final static int BOX_SUPPORT_ID_030e = 0x030e;
    public static List<SupportFunctionBean> getBoxSupportFunctionList() {
        //音箱功能列表初始化
        List<SupportFunctionBean> boxSupportFunctionList = new ArrayList<>();
//        boxSupportFunctionList.add(new SupportFunctionBean(BOX_SUPPORT_ID_0301, "音量设置与查询（0x00-0x02）", true, true));
//        boxSupportFunctionList.add(new SupportFunctionBean(BOX_SUPPORT_ID_0302, "播放控制（0x07-0x0a）", true, true));
//        boxSupportFunctionList.add(new SupportFunctionBean(BOX_SUPPORT_ID_0303, "EQ获取与设置（0x76、0x39）", true, true));
//        boxSupportFunctionList.add(new SupportFunctionBean(0x0304, "蓝牙配对（0x10）", false));
//        boxSupportFunctionList.add(new SupportFunctionBean(0x0305, "BT蓝牙断开（0x11）", false));
        boxSupportFunctionList.add(new SupportFunctionBean(BOX_SUPPORT_ID_0306, "BLE蓝牙断开", true, true));
//        boxSupportFunctionList.add(new SupportFunctionBean(BOX_SUPPORT_ID_0307, "电量获取（0x28）", true, true));
//        boxSupportFunctionList.add(new SupportFunctionBean(0x0308, "充电状态（0x29）", false));
//        boxSupportFunctionList.add(new SupportFunctionBean(BOX_SUPPORT_ID_0309, "恢复出厂设置（0x30）", true, true));
//        boxSupportFunctionList.add(new SupportFunctionBean(BOX_SUPPORT_ID_030a, "TF模式设置、蓝牙模式设置、获取TF模式状态（0x45、0x46、0x48）", false));
//        boxSupportFunctionList.add(new SupportFunctionBean(BOX_SUPPORT_ID_030b, "睡眠模式（0x63-0x65）", false));
//        boxSupportFunctionList.add(new SupportFunctionBean(BOX_SUPPORT_ID_030c, "灯效控制（0x6a-0x6b）", false));
//        boxSupportFunctionList.add(new SupportFunctionBean(BOX_SUPPORT_ID_030d, "FM控制（0x69、0x70-0x75）", false));
//        boxSupportFunctionList.add(new SupportFunctionBean(BOX_SUPPORT_ID_030e, "EQ获取与设置（0x76-0x77）", true, true));
//        boxSupportFunctionList.add(new SupportFunctionBean(0x030f, "LED指示灯状态（0x78）", false));
        return boxSupportFunctionList;
    }

    public static SupportFunctionBean getFunctionBySupportId(int deviceType, int supportId) {
        List<SupportFunctionBean> list = null;
        switch (deviceType) {
            case DEVICE_TYPE_TWS:
                list = getTwsSupportFunctionList();
                break;
            case DEVICE_TYPE_HEADSET:
                list = getHeadsetSupportFunctionList();
                break;
            case DEVICE_TYPE_BOX:
                list = getBoxSupportFunctionList();
                break;
            default:
                list = getTwsSupportFunctionList();
                break;
        }

        for (SupportFunctionBean supportFunctionBean : list) {
            if (supportFunctionBean.getSupportId() == supportId) {
                return supportFunctionBean;
            }
        }
        Log.e("DeviceConfigMessage", "找不到对应的功能==》getFunctionBySupportId: " + supportId);
        return null;
    }

}
